{extend name="$_admin_base_layout" /} {block name="body"}
<div class="container-fluid" style="padding-top: 10px; background-color: rgb(240, 242, 245);">
    <div class="panel">
        <div class="panel-body">
            <form class="form-inline form-search">
                <div class="form-group">
                    <label>状态：</label>
                    {html:select name="status" options="#data_status" selected="status" clazz="form-control" first="全部"/}
                </div>
                <div class="form-group">
                    <label>所属学院：</label>
                    {html:select id="office_id" name="office_id" options="office_tree" selected="office_id" clazz="form-control" first="全部"/}
                </div>
                <div class="form-group">
                    <label>所属专业：</label>
                    {html:select id="major_name" name="major_name" options="" selected="major_name" clazz="form-control" style="width:200px;" first="全部"/}
                </div>

                <div class="form-group">
                    <label>班级编码/名称：</label>
                    <input type="text" class="form-control" name="title" value="{$title|default=''}">
                </div>
                <button type="submit" class="btn btn-primary">查询</button>
                <button type="button" class="btn btn-default btn-reset">重置</button>
            </form>
        </div>
        <!-- 数据表格 -->
        <table class="table table-sorter">
            <!-- 表头 -->
            <thead>
            <tr>
                <th style="width: 20px;">#</th>
                <th>班级编码</th>
                <th>班级名称</th>
                <th>所在年级</th>
                <th>所属专业</th>
                <th>所属学院</th>
                <th>状态</th>
                <th style="width: 110px;">操作</th>
            </tr>
            </thead>
            <!-- 列表 -->
            <tbody>
            {notempty name="data_list"} {volist name="data_list" id="info"}
            <tr>
                <td>{$i}</td>
                <td>{$info.name}</td>
                <td>{$info.title}</td>
                <td>{$info.grade}</td>
                <td>{$info.major_text}</td>
                <td>{$info.office_text}</td>
                <td>{$info.status_text|raw}</td>
                <td>
                    <a href="{:url('edit',array('id'=>$info['id']))}" data-toggle="modal" data-icon="cogs"
                       data-title="编辑班级">编辑</a>
                    <a href="{:url('delete',array('id'=>$info['id']))}"
                       class="confirm ajax-get">删除</a></td>
            </tr>
            {/volist} {else/}
            <tr>
                <td class="text-center" colspan="8">aOh! 暂时还没有内容!</td>
            </tr>
            {/notempty}
            </tbody>
            <tfoot>
            <tr>
                <td colspan="8">
                    {$pager||raw}
                </td>
            </tr>
            </tfoot>
        </table>
    </div>
</div>
{/block}
{block name="sub_menu_action"}
<ul class="nav nav-pills" style="margin-right: 10px;">

    <li>
        <a href="{:url('add')}" data-toggle="modal" data-icon="cogs" data-title="新增班级">
            <i class="icon-plus"></i> 新增
        </a>
    </li>

</ul>
{/block}
{block name="script"}
<script>
    $(function () {
        var office_id = $("#office_id").val();
        if (office_id != '') {
            $.getJSON('{:url("edu/publiz/listMajor")}', {'office_id': office_id}, function ($response) {
                var $majorSelect = $('#major_name');
                var major_selected = '{$major_name}';
                $.each($response, function (index, item) {
                    if (major_selected == item.name){
                        $majorSelect.append('<option value="' + item.name + '" selected>' + item.title + '</option>');
                    } else{
                        $majorSelect.append('<option value="' + item.name + '">' + item.title + '</option>');
                    }

                })
            });
        }
        $("#office_id").change(function () {
            var office_id = $(this).val();
            $('#major_name').empty().append('<option value="">全部</option>');
            if (office_id != '') {
                $.getJSON('{:url("edu/publiz/listMajor")}', {'office_id': office_id}, function ($response) {
                    var $majorSelect = $('#major_name');
                    $.each($response, function (index, item) {
                        $majorSelect.append('<option value="' + item.name + '">' + item.title + '</option>');
                    })
                });
            }
        });
    });

</script>
{/block}
